/**
 * 获取当前窗口宽度
 */
export function getWindowWidth() {
  return window.innerWidth;
}

/**
 * 获取动态宽度
 */
export function getDialogWidth() {
  // 获取当前窗口宽度
  const currentWidth = getWindowWidth();

  if (currentWidth < 768) {
    return '98%';
  } else if (currentWidth >= 768 && currentWidth <= 1200) {
    return '60%';
  } else {
    return '70%';
  }
}

/**
 * 获取登录页动态样式
 */
export const getLoginStyle = () => {
  // 获取当前窗口宽度
  const currentWidth = getWindowWidth();
  let style = {
    fromWidth: {
      width: '60%'
    },
    titleShow: true,
    formStyle: {
      left: '60%',
      top: '52%',
      width: 'auto'
    },
    containerSize: {
      width: '60%',
      height: '60%'
    },
    containerStyle: {
      borderRadius: '10px'
    }
  };
  if (currentWidth <= 768) {
    style.fromWidth.width = '100%';
    style.titleShow = false;
    style.formStyle = {
      left: '50%',
      top: '70%',
      width: '80%'
    };
    style.containerSize = {
      width: '100%',
      height: '100%'
    };
    style.containerStyle.borderRadius = '0';
    return style;
  } else if (currentWidth > 768 && currentWidth <= 1200) {
    style.fromWidth.width = '100%';
    style.titleShow = false;
    style.formStyle = {
      left: '50%',
      top: '63%',
      width: 'auto'
    };
    style.containerSize = {
      width: '60%',
      height: '60%'
    };
    style.containerStyle.borderRadius = '10px';
    return style;
  } else {
    style.fromWidth.width = '60%';
    style.titleShow = true;
    style.formStyle = {
      left: '60%',
      top: '52%',
      width: 'auto'
    };
    style.containerSize = {
      width: '60%',
      height: '60%'
    };
    style.containerStyle.borderRadius = '10px';
    return style;
  }
};
